.ai-viewer-dialog {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #050505;
  color: #f8f8f5;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  z-index: 2147483647;
  overscroll-behavior: contain;
}

.ai-viewer-dialog[open] {
  display: flex;
  flex-direction: column;
  animation: ai-viewer-appear .22s ease-out both;
}

.ai-viewer-dialog::backdrop { background: #050505; }

.ai-viewer-shell {
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.ai-viewer-top,
.ai-viewer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 44px;
  padding: 0 clamp(8px,1.5vw,16px);
}

.ai-viewer-top h2 {
  overflow: hidden;
  max-width: calc(100% - 64px);
  margin: 0;
  color: #f8f8f5;
  font-size: clamp(15px,1.5vw,22px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-viewer-close {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.48);
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 30px;
  font-weight: 300;
  line-height: 1;
}

.ai-viewer-close:hover,
.ai-viewer-close:focus-visible {
  background: #f8f8f5;
  color: #050505;
}

.ai-viewer-close:focus-visible,
.ai-viewer-project:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.ai-viewer-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding: 0 clamp(8px,1.5vw,16px);
}

.ai-viewer-video {
  display: block;
  flex: none;
  max-width: 100%;
  max-height: 100%;
  background: #000;
  object-fit: contain;
}

.ai-viewer-error {
  position: absolute;
  bottom: 65px;
  left: 50%;
  width: max-content;
  max-width: calc(100vw - 40px);
  margin: 0;
  padding: 10px 14px;
  transform: translateX(-50%);
  background: rgba(10,10,10,.88);
  color: #fff;
  font-size: 13px;
  text-align: center;
}

.ai-viewer-error[hidden] { display: none; }

.ai-viewer-bottom { justify-content: flex-end; }
.ai-viewer-bottom[hidden] { display: none; }

.ai-viewer-project {
  color: rgba(255,255,255,.78);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-decoration: none;
  text-transform: uppercase;
}

.ai-viewer-project:hover { color: #fff; }

@keyframes ai-viewer-appear {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 640px) {
  .ai-viewer-top,
  .ai-viewer-bottom { min-height: 44px; }
  .ai-viewer-close { width: 38px; height: 38px; }
  .ai-viewer-top h2 { font-size: 15px; }
  .ai-viewer-project { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .ai-viewer-dialog[open] { animation: none; }
}
