.wj-paperdemo {
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  padding: 2.35rem max(1.15rem, env(safe-area-inset-left, 0px));
  padding-right: max(1.15rem, env(safe-area-inset-right, 0px));
  background: #f8fafc;
  text-align: left;
}

.wj-pd-inner {
  max-width: 68rem;
  margin: 0 auto;
}

.wj-paperdemo h2 {
  text-align: center;
}

.wj-pd-sub {
  max-width: 40rem;
  margin: -0.45rem auto 0.55rem;
  text-align: center;
  color: var(--muted);
}

.wj-pd-disclaimer {
  max-width: 44rem;
  margin: 0 auto 1.25rem;
  padding: 0 0.5rem;
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
}

.wj-pd-disclaimer-skill {
  display: inline-block;
  margin-top: 0.35rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: rgba(15, 23, 42, 0.82);
}

.wj-pd-disclaimer a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.wj-pd-disclaimer a:hover {
  color: var(--primary, #4f46e5);
}

.wj-pd-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: stretch;
}

.wj-pd-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 0.5rem;
  background: #fff;
  padding: 1rem;
  box-shadow: var(--shadow-card);
}

.wj-pd-panel--output {
  flex: 1;
  gap: 0.85rem;
}

.wj-pd-panel.is-locked .wj-pd-field--video,
.wj-pd-panel.is-locked .wj-pd-label,
.wj-pd-panel.is-locked .wj-pd-dimbox {
  pointer-events: none;
  user-select: none;
  filter: blur(1.4px);
  opacity: 0.55;
}

.wj-pd-dimbox {
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-radius: 0.45rem;
  padding: 0.75rem;
  background: #f8fafc;
}

.wj-pd-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  flex: 1;
  min-height: 0;
}

.wj-pd-panel .wj-pd-dimbox {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.wj-pd-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.84rem;
  font-weight: 750;
  color: rgba(15, 23, 42, 0.86);
}

.wj-pd-label input,
.wj-pd-label textarea {
  width: 100%;
  border: 1px solid rgba(99, 102, 241, 0.26);
  border-radius: 0.45rem;
  padding: 0.65rem 0.7rem;
  font: inherit;
  font-size: 0.9rem;
  color: #111827;
  background: #fff;
}

.wj-pd-label textarea {
  min-height: 7rem;
  resize: vertical;
  line-height: 1.45;
}

.wj-pd-help {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
}

.wj-pd-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.wj-pd-field-head {
  font-size: 0.84rem;
  font-weight: 750;
  color: rgba(15, 23, 42, 0.86);
}

.wj-pd-upload {
  position: relative;
}

.wj-pd-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

.wj-pd-upload-surface {
  min-height: 7.75rem;
  border: 2px dashed rgba(99, 102, 241, 0.42);
  border-radius: 0.55rem;
  background: linear-gradient(180deg, #fafbff 0%, #f1f5ff 100%);
  padding: 1.15rem 1rem 1.05rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.wj-pd-upload-surface:hover {
  border-color: rgba(79, 70, 229, 0.65);
  background: #eef2ff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08);
}

.wj-pd-upload-surface:focus-visible {
  outline: 2px solid rgba(79, 70, 229, 0.55);
  outline-offset: 2px;
}

.wj-pd-upload.is-dragover .wj-pd-upload-surface {
  border-color: #4f46e5;
  border-style: solid;
  background: #eef2ff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.14);
}

.wj-pd-upload.has-file .wj-pd-upload-surface {
  cursor: default;
  border-style: solid;
  border-color: rgba(99, 102, 241, 0.32);
  background: #fff;
}

.wj-pd-upload.has-file .wj-pd-upload-surface:hover {
  box-shadow: none;
}

.wj-pd-upload-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

/* [hidden] must win over display:flex above (otherwise empty + picked stacks and the check shows early). */
.wj-pd-upload-body[hidden] {
  display: none !important;
}

.wj-pd-upload-icon {
  color: rgba(79, 70, 229, 0.55);
  margin-bottom: 0.1rem;
}

.wj-pd-upload-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  color: rgba(15, 23, 42, 0.92);
  letter-spacing: -0.02em;
}

.wj-pd-upload-hint {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.wj-pd-upload-or {
  margin: 0.35rem 0 0.05rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(100, 116, 139, 0.95);
}

.wj-pd-upload-browse {
  appearance: none;
  margin-top: 0.2rem;
  border: 1px solid rgba(79, 70, 229, 0.45);
  border-radius: 0.5rem;
  padding: 0.55rem 1.15rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 750;
  color: #4338ca;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.1);
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}

.wj-pd-upload-browse:hover {
  background: #eef2ff;
  border-color: #4f46e5;
}

.wj-pd-upload-browse:focus-visible {
  outline: 2px solid rgba(79, 70, 229, 0.55);
  outline-offset: 2px;
}

.wj-pd-upload-browse:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.wj-pd-upload-body--picked {
  align-items: stretch;
  gap: 0.75rem;
  width: 100%;
  max-width: 100%;
}

.wj-pd-upload-picked-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
}

.wj-pd-upload-picked-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 999px;
  background: rgba(21, 128, 61, 0.12);
  color: #15803d;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
}

.wj-pd-upload-picked-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.12rem;
  min-width: 0;
  flex: 1;
}

.wj-pd-upload-picked-name {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 750;
  color: rgba(15, 23, 42, 0.92);
  word-break: break-word;
  max-width: 100%;
}

.wj-pd-upload-picked-meta {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
}

.wj-pd-upload-browse--secondary {
  align-self: center;
  margin-top: 0;
  font-size: 0.82rem;
  padding: 0.45rem 0.9rem;
}

.wj-pd-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.wj-pd-button {
  appearance: none;
  border: 0;
  border-radius: 0.45rem;
  padding: 0.66rem 0.95rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 750;
  color: #fff;
  background: #4f46e5;
  cursor: pointer;
}

.wj-pd-button:hover {
  background: #4338ca;
}

.wj-pd-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.wj-pd-status {
  min-height: 1.3rem;
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.wj-pd-status[data-state="error"] {
  color: #991b1b;
}

.wj-pd-status[data-state="busy"] {
  color: #4f46e5;
}

.wj-pd-preview-wrap {
  margin: 0;
  flex: 0 0 auto;
  width: 100%;
}

.wj-pd-video-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 0.5rem;
  background: #0f172a;
}

.wj-pd-video-frame video {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.wj-pd-progress {
  flex: 0 0 auto;
  margin-top: 0;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 0.5rem;
  padding: 0.85rem;
  background: #fff;
}

.wj-pd-progress[data-state="idle"] {
  flex: 1 1 auto;
  min-height: 11rem;
  margin-top: 0;
  border-style: dashed;
  border-color: rgba(99, 102, 241, 0.28);
  background: #f8fafc;
}

.wj-pd-progress[data-state="idle"] > * {
  opacity: 0;
  pointer-events: none;
}

.wj-pd-panel--output .wj-pd-results:empty {
  flex: 1 1 auto;
  min-height: 4rem;
  margin-top: 0;
  border: 1px dashed rgba(99, 102, 241, 0.22);
  border-radius: 0.5rem;
  background: #fafbfc;
}

.wj-pd-panel--output .wj-pd-results:not(:empty) {
  flex: 0 1 auto;
  margin-top: 0;
}

.wj-pd-progress__top {
  display: grid;
  grid-template-columns: 1.45rem minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
}

.wj-pd-spinner {
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.1rem;
  border: 2px solid rgba(79, 70, 229, 0.18);
  border-top-color: #4f46e5;
  border-radius: 999px;
  animation: wj-pd-spin 0.8s linear infinite;
}

.wj-pd-progress[data-state="complete"] .wj-pd-spinner,
.wj-pd-progress[data-state="error"] .wj-pd-spinner {
  animation: none;
  border-color: transparent;
}

.wj-pd-progress[data-state="complete"] .wj-pd-spinner {
  background: #15803d;
  box-shadow: inset 0 0 0 4px #fff;
}

.wj-pd-progress[data-state="error"] .wj-pd-spinner {
  background: #b91c1c;
  box-shadow: inset 0 0 0 4px #fff;
}

.wj-pd-progress__title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 800;
  color: #111827;
}

.wj-pd-progress__detail {
  min-height: 1.2rem;
  margin: 0.16rem 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted);
}

.wj-pd-progress__bar {
  overflow: hidden;
  height: 0.42rem;
  margin-top: 0.72rem;
  border-radius: 999px;
  background: #e5e7eb;
}

.wj-pd-progress__bar span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #4f46e5;
  transition: width 180ms ease;
}

.wj-pd-progress[data-mode="indeterminate"] .wj-pd-progress__bar span {
  width: 42%;
  animation: wj-pd-bar 1.15s ease-in-out infinite;
}

.wj-pd-progress[data-state="complete"] .wj-pd-progress__bar span {
  width: 100%;
  background: #15803d;
}

.wj-pd-progress[data-state="error"] .wj-pd-progress__bar span {
  width: 100%;
  background: #b91c1c;
}

.wj-pd-progress__steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.wj-pd-progress__steps li {
  min-width: 0;
  border-radius: 999px;
  padding: 0.28rem 0.42rem;
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 750;
  text-align: center;
  white-space: nowrap;
}

.wj-pd-progress__steps li[data-state="active"] {
  background: rgba(79, 70, 229, 0.1);
  color: #4338ca;
}

.wj-pd-progress__steps li[data-state="done"] {
  background: rgba(21, 128, 61, 0.11);
  color: #15803d;
}

.wj-pd-dim-tools {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.wj-pd-linkbutton {
  appearance: none;
  border: 0;
  padding: 0;
  color: var(--primary);
  background: transparent;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.wj-pd-linkbutton:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.wj-pd-dims {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.42rem 0.6rem;
  max-height: 18.5rem;
  overflow: auto;
  padding-right: 0.25rem;
}

.wj-pd-panel--dropzone .wj-pd-dims {
  flex: 1 1 auto;
  max-height: none;
  min-height: 10rem;
}

.wj-pd-dim {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  font-size: 0.78rem;
  color: rgba(15, 23, 42, 0.82);
}

.wj-pd-dim span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.wj-pd-dim.is-disabled {
  opacity: 0.48;
}

.wj-pd-results {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.34rem;
  margin-top: 0;
}

@keyframes wj-pd-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes wj-pd-bar {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(245%);
  }
}

@media (max-width: 62rem) {
  .wj-pd-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 38rem) {
  .wj-pd-dims {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 36rem) {
  .wj-paperdemo {
    padding-top: 1.65rem;
    padding-bottom: 1.65rem;
  }

  .wj-pd-progress[data-state="idle"] {
    min-height: 8rem;
  }

  .wj-pd-upload-surface {
    min-height: 6.75rem;
    padding: 1rem 0.75rem 0.95rem;
  }

  .wj-pd-panel {
    padding: 0.85rem 0.75rem;
  }

  .wj-pd-field-head {
    font-size: 0.8rem;
  }

  .wj-pd-upload-title {
    font-size: 0.92rem;
  }
}

@media (pointer: coarse) {
  .wj-pd-upload-browse {
    min-height: 2.75rem;
    padding-top: 0.58rem;
    padding-bottom: 0.58rem;
  }

  .wj-pd-button {
    min-height: 2.75rem;
    padding-left: 1.15rem;
    padding-right: 1.15rem;
  }

  .wj-pd-upload-browse--secondary {
    min-height: 2.6rem;
  }
}
