/* Every on-demand preview shares this shell and toolbar. */
html.preview-modal-open { overflow: hidden; }

.preview-modal {
  box-sizing: border-box;
  position: fixed;
  inset: 0;
  width: 80%;
  height: 80vh;
  height: 80dvh;
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: rgb(var(--c-bg));
  color: rgb(var(--c-body));
  font-family: 'Noto Sans KR', system-ui, sans-serif;
}

.preview-modal[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
.preview-modal::backdrop { background: rgb(0 0 0 / 65%); }

.preview-modal-toolbar {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  padding-top: max(4px, env(safe-area-inset-top));
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  border-bottom: 1px solid rgb(var(--c-border));
}

.preview-modal-title {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 20px;
  font-weight: 500;
  text-align: left;
}

.preview-modal-action {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

/* Compact preview controls; other site buttons keep their default size. */
.preview-modal-toolbar .btn--icon {
  flex-basis: 32px;
  min-width: 32px;
  min-height: 32px;
  width: 32px;
  height: 32px;
}
.preview-modal-toolbar .material-symbols-outlined {
  font-size: 18px;
}

.preview-modal-body { min-height: 0; min-width: 0; overflow: hidden; }

/* Shared loading/failure presentation; each viewer owns its loading behavior. */
.preview-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 24px;
  text-align: center;
}
.preview-status-copy { max-width: 34ch; }
.preview-status-title {
  margin: 0;
  color: rgb(var(--c-body));
  font-size: 14px;
  font-weight: 500;
  line-height: 1.6;
}
.preview-status-description {
  margin: 8px 0 0;
  color: rgb(var(--c-muted));
  font-size: 13px;
  line-height: 1.7;
}
.preview-status-spinner {
  display: block;
  width: 20px;
  height: 20px;
  margin: 0 auto 12px;
  border: 2px solid rgb(var(--c-border));
  border-top-color: rgb(var(--c-muted));
  border-radius: 50%;
  animation: preview-loading 0.9s linear infinite;
}
.preview-status-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}
.preview-status[hidden], .preview-status [hidden] { display: none; }
@keyframes preview-loading { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .preview-status-spinner { animation: none; }
}
/* Keep short labels inside the panel edges and above its content. */
.preview-modal-action [data-tip]::after { left: auto; right: 0; transform: none; }

@media (max-width: 600px) {
  .preview-modal-toolbar {
    padding-left: 8px;
    padding-right: 8px;
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }
}
