.xz-dialog {
  --xz-accent: #245ac6;
  box-sizing: border-box;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #fff;
  color: #263244;
  font: 14px/1.5 system-ui, sans-serif;
  overscroll-behavior: contain;
}
.xz-dialog::backdrop { background: #fff; }
.xz-dialog *, .xz-dialog *::before, .xz-dialog *::after { box-sizing: border-box; }
.xz-dialog[open] { display: grid; grid-template-columns: 100px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.xz-dialog[open][data-has-title="true"] { grid-template-columns: 100px minmax(0, 1fr) clamp(180px, 20vw, 280px); }
.xz-dialog :is(.xz-button, .xz-thumb) { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.xz-dialog button:focus-visible { outline: 3px solid var(--xz-accent); outline-offset: 3px; }
.xz-toolbar { position: absolute; top: 0; left: 100px; right: 0; z-index: 3; display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 8px max(16px, env(safe-area-inset-right)); pointer-events: none; }
.xz-toolbar > * { pointer-events: auto; }
.xz-count { margin-right: auto; padding: 4px 8px; border-radius: 6px; background: #fff; color: #697386; font-variant-numeric: tabular-nums; }
.xz-button { display: grid; place-items: center; flex-shrink: 0; width: 44px; height: 44px; padding: 10px; border: 1px solid #748094; border-radius: 50%; background: #fff; }
.xz-button:hover { background: #f0f4fa; }
.xz-button:disabled { opacity: .35; cursor: default; }
.xz-button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.xz-thumbs { grid-column: 1; grid-row: 1 / -1; display: flex; flex-direction: column; gap: 10px; overflow-x: hidden; overflow-y: auto; min-height: 0; padding: max(16px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom)); border-right: 1px solid #edf0f4; overscroll-behavior: contain; scrollbar-width: none; }
.xz-thumbs::-webkit-scrollbar { display: none; }
.xz-thumb { flex: 0 0 72px; width: 72px; height: 72px; padding: 4px; border: 2px solid transparent; border-radius: 8px; background: #f7f8fa; }
.xz-thumb[aria-current="true"] { border-color: var(--xz-accent); background: #fff; }
.xz-thumb img { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: 3px; }
.xz-thumb-video { position: relative; }
.xz-thumb-video::after { content: '▶'; position: absolute; inset: auto 4px 4px auto; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #263244; color: #fff; font-size: 12px; }
.xz-video { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); aspect-ratio: 16 / 9; background: #000; --plyr-color-main: #245ac6; }
.xz-video .plyr { width: 100%; height: 100%; }
.xz-video iframe { border: 0; }
.xz-dialog[data-media="video"] .xz-status { inset: 0 64px auto; z-index: 2; padding: 8px; background: #fff; }
.xz-dialog[data-media="video"] .xz-status:empty { display: none; }
.xz-main { grid-column: 2; grid-row: 1; position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.xz-stage { position: absolute; inset: 0 64px; overflow: hidden; touch-action: none; user-select: none; }
.xz-image { position: absolute; top: 50%; left: 50%; max-width: none; max-height: none; margin: 0; transform-origin: center; user-select: none; -webkit-user-drag: none; }
.xz-stage[data-zoomed="true"] { cursor: grab; }
.xz-stage[data-dragging="true"] { cursor: grabbing; }
.xz-prev, .xz-next { position: absolute; top: 50%; transform: translateY(-50%); z-index: 1; }
.xz-prev { left: 10px; }
.xz-next { position: fixed; right: 10px; z-index: 2; }
.xz-title { grid-column: 3; grid-row: 1; align-self: start; max-height: calc(50dvh - 112px); margin: 72px 0 0; padding: 16px; overflow: auto; overflow-wrap: anywhere; font-size: 16px; font-weight: 400; }
.xz-title:focus-visible { outline: 3px solid var(--xz-accent); outline-offset: -3px; }
.xz-tools { position: absolute; z-index: 2; bottom: 8px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; padding: 6px; border-radius: 12px; background: #fff; max-width: calc(100% - 16px); flex-wrap: wrap; justify-content: center; }
.xz-tools .xz-button { width: 44px; height: 44px; }
.xz-help { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.xz-status { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; pointer-events: none; }
.xz-dialog [hidden] { display: none !important; }
@media (max-width: 768px) {
  .xz-dialog[open], .xz-dialog[open][data-has-title="true"] { display: flex; flex-direction: column; justify-content: flex-start; overflow-y: auto; }
  .xz-toolbar { position: relative; left: auto; right: auto; order: 0; flex: 0 0 auto; padding-top: max(8px, env(safe-area-inset-top)); }
  .xz-main { order: 2; flex: 0 0 auto; width: 100%; height: var(--xz-mobile-height, 50vh); min-height: 100px; }
  .xz-stage { inset: 0; }
  .xz-title { order: 4; align-self: stretch; flex: 0 0 auto; margin: 0; padding: 8px 16px; font-size: 14px; max-height: 20vh; overflow: auto; }
  .xz-thumbs { order: 3; flex: 0 0 auto; flex-direction: row; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; border-right: 0; border-top: 1px solid #edf0f4; padding: 10px 12px max(10px, env(safe-area-inset-bottom)); gap: 8px; }
  .xz-thumbs::-webkit-scrollbar { display: block; height: 8px; }
  .xz-thumbs::-webkit-scrollbar-thumb { background: #748094; border-radius: 4px; }
  .xz-thumb { flex-basis: 64px; width: 64px; height: 64px; }
  .xz-prev { left: 8px; }
  .xz-next { position: absolute; right: 8px; }
  .xz-dialog[data-media="video"] .xz-status { inset: 0 56px auto; font-size: 12px; }
}

/* Immersive video layout overrides both desktop and mobile photo layouts. */
.xz-dialog[open][data-media="video"] { display: block; background: #000; color: #fff; overflow: hidden; }
.xz-dialog[data-media="video"] .xz-thumbs,
.xz-dialog[data-media="video"] .xz-count { display: none; }
.xz-dialog[data-media="video"] .xz-title { position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; overflow: hidden; clip-path: inset(50%); }
.xz-dialog[data-media="video"] .xz-main { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; }
.xz-dialog[data-media="video"] .xz-toolbar { position: absolute; inset: 0 0 auto auto; padding-top: max(8px, env(safe-area-inset-top)); }
.xz-dialog[data-media="video"] .xz-video { inset: 0; width: 100%; height: 100%; transform: none; aspect-ratio: auto; }
.xz-video .plyr { justify-content: center; min-width: 0; }
.xz-video .plyr--html5 .plyr__video-wrapper { width: 100%; height: 100%; }
.xz-video video { object-fit: contain; }
.xz-video .plyr__video-embed { flex: none; width: min(100%, calc(100dvh * var(--xz-video-ratio, 1.777778))); height: min(100dvh, calc(100vw / var(--xz-video-ratio, 1.777778))); padding-bottom: 0; }
/* Embedded providers use Plyr controls; let mouse/touch events reach the host. */
.xz-video .plyr--full-ui iframe { pointer-events: none; }
.xz-dialog[data-media="video"] :is(.xz-close, .xz-prev, .xz-next) { color: #fff; background: #171b22e6; border-color: #a4adbb; opacity: 1; transition: opacity .15s; }
.xz-dialog[data-media="video"] .xz-prev,
.xz-dialog[data-media="video"] .xz-next { position: absolute; }
.xz-dialog[data-media="video"] .xz-button:focus-visible { outline-color: #fff; }
.xz-dialog[data-media="video"][data-controls-hidden="true"] :is(.xz-close, .xz-prev, .xz-next) { opacity: 0; pointer-events: none; }
.xz-dialog[data-media="video"][data-controls-hidden="true"] .xz-video { cursor: none; }
.xz-dialog[data-media="video"] .xz-status { inset: 72px 64px auto; background: #171b22e6; color: #fff; border-radius: 8px; }
@media (prefers-reduced-motion: reduce) {
  .xz-dialog[data-media="video"] :is(.xz-close, .xz-prev, .xz-next) { transition: none; }
}
