.client-gallery {
  position: fixed;
  inset: 0;
  width: min(70rem, calc(100% - 2rem));
  height: min(52rem, calc(100% - 2rem));
  height: min(52rem, calc(100dvh - 2rem));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid #c7bca8;
  border-radius: 9px;
  background: var(--card, #fffdf8);
  color: var(--ink, #272723);
  box-shadow: 0 20px 80px rgb(30 23 18 / 45%);
}

.client-gallery::backdrop { background: rgb(34 28 22 / 72%); }
.client-gallery-panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; width: 100%; height: 100%; }

.client-gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--rule, #dad4c9);
}

.client-gallery-header h2 {
  min-width: 0;
  margin: 0;
  font: 400 clamp(1.25rem, 3.8vw, 2rem)/1.13 var(--serif, Georgia, serif);
  overflow-wrap: anywhere;
}

.client-gallery button {
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid #ac9f8b;
  border-radius: 4px;
  background: #fcf8f0;
  color: #47392c;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 670;
  cursor: pointer;
  touch-action: manipulation;
}

.client-gallery button:hover { background: #eee3d3; }
.client-gallery button:focus-visible { outline: 2px solid #815b32; outline-offset: 2px; }
.client-gallery-close { flex: none; }

.client-gallery-content {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  padding: 0.55rem 0.55rem 0;
}

.client-gallery-stage {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 4px;
  background: #2b2521;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.client-gallery-image { position: absolute; inset: 0; }
.client-gallery-image img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }

.client-gallery-message {
  position: absolute;
  right: 0.4rem;
  bottom: 0.4rem;
  left: 0.4rem;
  width: fit-content;
  margin: 0 auto;
  padding: 0.35rem 0.55rem;
  border-radius: 3px;
  background: #342c25;
  color: #fff9ed;
  font-size: 0.875rem;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
}

.client-gallery-message:empty { display: none; }

.client-gallery-details {
  max-height: 18vh;
  max-height: 18dvh;
  margin-top: 0.55rem;
  padding: 0.45rem 0.55rem;
  overflow: auto;
  border-radius: 4px;
  background: #f3ebde;
  overscroll-behavior: contain;
}

.client-gallery-rating { margin: 0; color: #725127; font-size: 0.875rem; font-weight: 720; }
.client-gallery-review { margin: 0; color: #584838; font-size: 0.875rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.client-gallery-rating:not([hidden]) + .client-gallery-review:not([hidden]) { margin-top: 0.3rem; }
.client-gallery-details:focus-visible { outline: 2px solid #815b32; outline-offset: -2px; }

.client-gallery-navigation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(3rem, auto) minmax(0, 1fr);
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem;
}

.client-gallery-previous { justify-self: end; }
.client-gallery-count { grid-column: 2; margin: 0; color: #604d39; font-size: 0.875rem; font-weight: 660; font-variant-numeric: tabular-nums; text-align: center; }
.client-gallery-next { justify-self: start; }

@media (max-width: 32rem), (pointer: coarse) and (max-height: 29rem) {
  .client-gallery {
    width: 100%;
    height: 100%;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .client-gallery-header {
    padding-top: max(0.5rem, env(safe-area-inset-top, 0px));
    padding-right: max(0.65rem, env(safe-area-inset-right, 0px));
    padding-left: max(0.65rem, env(safe-area-inset-left, 0px));
  }

  .client-gallery-content {
    padding-right: max(0.4rem, env(safe-area-inset-right, 0px));
    padding-left: max(0.4rem, env(safe-area-inset-left, 0px));
  }

  .client-gallery-navigation { padding-bottom: max(0.55rem, env(safe-area-inset-bottom, 0px)); }
}

@media (min-width: 48rem) and (min-height: 28rem) {
  .client-gallery-content:has(.client-gallery-details:not([hidden])) {
    grid-template-columns: minmax(0, 1fr) minmax(12rem, 17rem);
    grid-template-rows: minmax(0, 1fr);
    gap: 0.65rem;
  }

  .client-gallery-details { max-height: none; margin-top: 0; padding: 0.8rem; }
}
