.workbench-ai-file-preview-mask {
  --workbench-ai-preview-sidebar-offset: var(--sidebar-expanded-width, 304px);
  --workbench-ai-preview-edge-padding: 24px;

  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  grid-template-columns: var(--workbench-ai-preview-sidebar-offset) minmax(0, 1fr);
  align-items: center;
  justify-items: center;
  padding: var(--workbench-ai-preview-edge-padding);
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

:global(.app.sidebar-collapsed) .workbench-ai-file-preview-mask {
  --workbench-ai-preview-sidebar-offset: var(--sidebar-collapsed-width, 64px);
}

.workbench-ai-file-preview-dialog {
  grid-column: 2;
  justify-self: center;
  width: min(
    1160px,
    calc(100vw - var(--workbench-ai-preview-sidebar-offset) - (var(--workbench-ai-preview-edge-padding) * 2))
  );
  max-height: calc(100vh - (var(--workbench-ai-preview-edge-padding) * 2));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  padding: 22px;
  border: 1px solid rgba(var(--ai-theme-rgb), 0.16);
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 28px 56px rgba(15, 23, 42, 0.2);
}

.workbench-ai-file-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.workbench-ai-file-preview-badge {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 4px;
  background: rgba(47, 124, 255, 0.11);
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
}

.workbench-ai-file-preview-head h3 {
  margin: 10px 0 0;
  color: #0f172a;
  font-size: 20px;
  line-height: 1.4;
  font-weight: 850;
}

.workbench-ai-file-preview-close {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #d7e0ea;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.94);
  color: #475569;
  font-size: 18px;
}

.workbench-ai-file-preview-body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 16px;
  overflow: hidden;
}

.workbench-ai-file-preview-source,
.workbench-ai-file-preview-insight {
  min-height: 0;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.workbench-ai-file-preview-source {
  display: grid;
  place-items: center;
  background: #f8fafc;
}

.workbench-ai-file-preview-image,
.workbench-ai-file-preview-frame {
  width: 100%;
  height: 100%;
  min-height: 520px;
  border: 0;
  object-fit: contain;
  background: #ffffff;
}

.workbench-ai-file-preview-insight {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  align-content: start;
  gap: 14px;
  padding: 18px;
  overflow-y: auto;
  background: #ffffff;
}

.workbench-ai-file-preview-insight-head {
  display: grid;
  gap: 6px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e2e8f0;
}

.workbench-ai-file-preview-insight-head span,
.workbench-ai-file-preview-section > span {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.workbench-ai-file-preview-insight-head strong {
  color: #0f172a;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 850;
}

.workbench-ai-file-preview-status {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: start;
  padding: 0 12px;
  border: 1px solid #dbeafe;
  border-radius: 4px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 800;
}

.workbench-ai-file-preview-status.is-recognizing i {
  animation: workbenchAiOcrSpin 840ms linear infinite;
}

@keyframes workbenchAiOcrSpin {
  to {
    transform: rotate(360deg);
  }
}

.workbench-ai-file-preview-status.is-recognized {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #047857;
}

.workbench-ai-file-preview-status.is-failed {
  border-color: #fecaca;
  background: #fff1f2;
  color: #dc2626;
}

.workbench-ai-file-preview-section {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 4px;
  background: #f8fafc;
}

.workbench-ai-file-preview-section dl {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
}

.workbench-ai-file-preview-section dt,
.workbench-ai-file-preview-section dd,
.workbench-ai-file-preview-section p {
  margin: 0;
  color: #334155;
  font-size: 13px;
  line-height: 1.55;
}

.workbench-ai-file-preview-section dt {
  color: #64748b;
  font-weight: 750;
}

.workbench-ai-file-preview-section dd {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 760;
}

.workbench-ai-file-preview-state {
  min-height: 320px;
  display: grid;
  place-items: center;
  gap: 10px;
  color: #475569;
  font-size: 14px;
  font-weight: 750;
  text-align: center;
}

.workbench-ai-file-preview-state i {
  font-size: 26px;
}

.workbench-ai-preview-fade-enter-active,
.workbench-ai-preview-fade-leave-active {
  transition: opacity 160ms ease;
}

.workbench-ai-preview-fade-enter-from,
.workbench-ai-preview-fade-leave-to {
  opacity: 0;
}

@media (max-width: 900px) {
  .workbench-ai-file-preview-mask {
    --workbench-ai-preview-sidebar-offset: 0px;
    --workbench-ai-preview-edge-padding: 12px;

    grid-template-columns: minmax(0, 1fr);
    padding: var(--workbench-ai-preview-edge-padding);
  }

  .workbench-ai-file-preview-dialog {
    grid-column: 1;
    width: calc(100vw - (var(--workbench-ai-preview-edge-padding) * 2));
    max-height: calc(100vh - (var(--workbench-ai-preview-edge-padding) * 2));
    padding: 14px;
  }

  .workbench-ai-file-preview-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .workbench-ai-file-preview-image,
  .workbench-ai-file-preview-frame {
    min-height: 300px;
    max-height: 46vh;
  }

  .workbench-ai-file-preview-insight {
    overflow: visible;
  }
}

@media (prefers-reduced-motion: reduce) {
  .workbench-ai-preview-fade-enter-active,
  .workbench-ai-preview-fade-leave-active {
    transition: none;
  }
}
